#function to allow changing of host config file
#function goes to config file path given, reads in the file and changes the current host

import os
from {{ module.lower() }} import {{ module }}

def change_host(host,path_to_locales):
	"""
	Changes the current host in the config file
	"""
	
	lines = []
	with open(path_to_locales,"r") as fh:
		
		#read all lines in file
		lines = fh.readlines() 
		
		#change the second row
		lines[1] = "current,"+host

	with open(path_to_locales,"w") as fo:

		fo.write('\n'.join(lines))
			
# ask for the new host
host = raw_input("\n Please enter new database ip (xxx.xxx.xxx.xxx): ")

if host == "":
	print "\n No host entered. Current host: " + {{ module }}.get_current_host()
else:
	path_to_locales = os.path.normpath({{ module }}.get_project_root()+"/config/locales.csv")
	change_host(host,path_to_locales)
	print "\n Host changed to: " + host


